package com.cloudcc.mobile.bull;

import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.baidu.location.BDLocation;
import com.baidu.location.BDLocationListener;
import com.baidu.mapapi.model.LatLng;
import com.baidu.mapapi.utils.DistanceUtil;
import com.cloudcc.mobile.R;
import com.cloudcc.mobile.dialog.BackTrueDialog;
import com.cloudcc.mobile.dialog.CallLogLoadingDialog;
import com.cloudcc.mobile.event.AttendanceEventList;
import com.cloudcc.mobile.manager.LocationManager;
import com.cloudcc.mobile.manager.RunTimeManager;
import com.cloudcc.mobile.manager.UrlManager;
import com.cloudcc.mobile.presenter.AttendancePresenter;
import com.cloudcc.mobile.presenter.DynamicControl;
import com.cloudcc.mobile.weight.DialogUtils;
import com.google.gson.Gson;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.RequestParams;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest;
import com.litesuits.android.log.Log;
import com.mypage.adapter.NCheckDataAdapter;
import com.mypage.bean.CheckInBean;

import org.json.JSONException;
import org.json.JSONObject;

import java.text.SimpleDateFormat;
import java.util.Date;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class GongniuCheckinActivity extends Activity implements BackTrueDialog.BackTrue {

    @Bind(R.id.bar_title_text)
    TextView barTitleText;

    @Bind(R.id.CheckInHistory)
    ImageView CheckInHistory;

    @Bind(R.id.layoutShow)
    LinearLayout layoutShow;

    @Bind(R.id.adkBtn)
    ImageView adkBtn;

    @Bind(R.id.relativeShow)
    RelativeLayout relativeShow;

    @Bind(R.id.listCheckIn)
    ListView listCheckIn;

    @Bind(R.id.tvShowTip)
    TextView tvShowTip;

    public NCheckDataAdapter mAdapter;
    @Bind(R.id.imgBtnGowork)
    ImageButton imgBtnGowork;

    @Bind(R.id.imgBtnNoon)
    ImageButton imgBtnNoon;

    @Bind(R.id.imgBtnOffwork)
    ImageButton imgBtnOffwork;

    private boolean isHelp = false;

    private AttendancePresenter mAttendancePresenter = new AttendancePresenter();

    private AttendancePresenter.AttendanceHomeEntity mHomeEntity;
    public SharedPreferences settings;
    public SharedPreferences.Editor editor;

    private BackTrueDialog tureDialog;
    boolean isStop=false;
     String kqId;

    public static GongniuCheckinActivity instancesa = null;
    private DynamicControl upimage = new DynamicControl();

    /**
     * @param savedInstanceState 新建考勤记录
     */

    //////////////////////////////////////////
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_gongniu_checkin);
        ButterKnife.bind(this);
        settings = this.getSharedPreferences("mIds", 0);
        editor = settings.edit();
        instancesa = this;
        tureDialog = new BackTrueDialog(this, R.style.DialogLoadingTheme);
        getDataSend();
    }

    @Override
    protected void onPause() {
        isStop=true;
        super.onPause();
    }
    @Override
    protected void onResume() {
        getDataSend();
        isStop=false;
        super.onResume();
    }


    @OnClick({R.id.mBtnBack, R.id.CheckInHistory, R.id.layoutShow, R.id.adkBtn, R.id.relativeShow, R.id.imgBtnGowork, R.id.imgBtnNoon, R.id.imgBtnOffwork, R.id.imgBtnLocation})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.mBtnBack:
                if (isHelp) {
                    setKaoQinShowView();
                } else {
                    finish();
                }

                break;
            case R.id.CheckInHistory:

//                Intent intent = new Intent(this, GongniuCheckinHistoryActivity.class);
                Intent intent = new Intent(this, GongniuCheckinHistoryNewActivity.class);
                startActivity(intent);

                break;
            case R.id.layoutShow:
                break;
            case R.id.adkBtn:
                setHelpShowView();
                break;
            case R.id.relativeShow:
                break;

            case R.id.imgBtnGowork://上班
                mDingwei = "上班";
                startLocal(true);
//                sendDataHttp_();
                break;
            case R.id.imgBtnNoon://中午
                mDingwei = "中午";
                startLocal(true);
//sendDataHttp_();
                break;

            case R.id.imgBtnOffwork://下班
                mDingwei = "下班";
                startLocal(true);
//                sendDataHttp_();
                break;

            case R.id.imgBtnLocation://定位
                mDingwei = "定位";
                startLocal(true);
//                sendDataHttp_();
                break;
        }
    }

    public String mDingwei = "";

    /**
     * 点击帮助的时候显示帮助的View
     */
    public void setHelpShowView() {
        isHelp = true;
        adkBtn.setVisibility(View.GONE);
        barTitleText.setText("使用帮助");
        CheckInHistory.setVisibility(View.INVISIBLE);
        relativeShow.setVisibility(View.GONE);
        layoutShow.setVisibility(View.VISIBLE);

    }

    /**
     * 点击帮助返回显示考勤的View
     */
    public void setKaoQinShowView() {
        isHelp = false;
        adkBtn.setVisibility(View.VISIBLE);
        barTitleText.setText("考勤");
        CheckInHistory.setVisibility(View.VISIBLE);
        relativeShow.setVisibility(View.VISIBLE);
        layoutShow.setVisibility(View.GONE);

    }

    CallLogLoadingDialog callLogLoadingDialogx;

    protected void showDialogTy(String text) {
        callLogLoadingDialogx = new CallLogLoadingDialog(GongniuCheckinActivity.this, R.style.DialogLoadingTheme);
        callLogLoadingDialogx.show();
        callLogLoadingDialogx.settext(text);
    }

    /**
     * 开始定位
     *
     * @param isShowWaiting 是否显示 定位进行的时候的dialog 提示
     */
    private String mEns = RunTimeManager.getInstance().getlanguage();
    private boolean shouldShowWaiting = false;// 是否显示dialog 在定位的时候

    private void startLocal(boolean isShowWaiting) {
        shouldShowWaiting = isShowWaiting;
        if (isShowWaiting) {// 显示定位的等待提示
            if ("en".equals(mEns)) {
                showDialogTy("Is positioning, please wait...");
            } else {
                showDialogTy("正在定位,请稍等...");
            }

        }
        LocationManager.getInstance().registerListener(mListener);
        LocationManager.getInstance().requestLocal();
    }

    private BDLocation lastDBLocation;// 最新的定位位置
    private BDLocationListener mListener = new BDLocationListener() {
        @Override
        public void onReceiveLocation(BDLocation location) {
            if (null != location && location.getLocType() != BDLocation.TypeServerError) {
                lastDBLocation = location;
                LocationManager.getInstance().stopRequestLocal();
                LocationManager.log(lastDBLocation);
                onLocalFinish(true);
            } else {
                if (null != location) {
                    if ("en".equals(mEns)) {
                        showToast("Positioning failed, please try again! Error code:" + location.getLocType());
                    } else {
                        showToast("定位失败，请重试! 错误码:" + location.getLocType());
                    }

                }
                onLocalFinish(false);
            }
        }
    };

    /**
     * 定位结束的时候
     *
     * @param success 是否定位成功
     */
    private void onLocalFinish(boolean success) {
        if (shouldShowWaiting) {// 刚才显示dialog 了 取消吊
            dismissWainting();
        }
        if (!success) {
            if ("en".equals(mEns)) {
                showToast("Location failed, please try again");
            } else {
                showToast("定位失败,请重试");
            }


            return;
        }
        checkToNet(1);//在这个类中随意数字

    }

    /**
     * show toast
     *
     * @param msg
     */
    protected void showToast(String msg) {
        if (null != msg && !TextUtils.isEmpty(msg)) {
            Toast.makeText(this, msg, 0).show();
        }
    }

    /**
     * 取消 显示等待的dialog
     */
    protected void dismissWainting() {
        if (callLogLoadingDialogx != null) {
            callLogLoadingDialogx.dismiss();
            callLogLoadingDialogx = null;
        }
        showLocResult();
    }

    public void onDestroy() {
        LocationManager.getInstance().unregisterlistener(mListener);
        super.onDestroy();
    }

    private void showLocResult() {
        showLocalResult(new DialogUtils.DialogOnClickListener() {
            @Override
            public void onClickPositive(Dialog dialog) {
                dialog.cancel();
            }

            @Override
            public void onClickNegative(Dialog dialog) {
                dialog.cancel();
            }
        });
    }

    /**
     * 显示 当前位置dialog
     */
    private int attendanceTypeIndex = 1;// 默认是 内勤

    private void showLocalResult(DialogUtils.DialogOnClickListener l) {
        String addr = LocationManager.getDetailAddr(lastDBLocation, true);

        // 计算 距离
        String distanceStr = "";
        if (null != lastDBLocation
                && hasCheckCenter()
                && (!(attendanceTypeIndex == 2 && mHomeEntity.checkloc.type == 1))) {// 存在坐标点
            // 的时候才显示
            // 距离
            LatLng lastLatLng = new LatLng(lastDBLocation.getLatitude(),
                    lastDBLocation.getLongitude());
            LatLng latLng = new LatLng(mHomeEntity.checkloc.lat,
                    mHomeEntity.checkloc.lon);
            double distance = DistanceUtil.getDistance(lastLatLng, latLng);
            distanceStr = "距离签到点:" + String.valueOf((int) distance) + "m";
        }

        if (TextUtils.isEmpty(addr)) {
            return;
        }
        String message = addr + "\n" + distanceStr;
        if ("定位".equals(mDingwei)) {
            if ("en".equals(mEns)) {
                DialogUtils.showWarnGongniu(this, "prompt", "position" + message, l);
            } else {
                DialogUtils.showWarnGongniu(this, "提示", "位置：" + message, l);
            }
        }
    }

    /**
     * 服务器是否配置了签到中心点
     *
     * @return 2016-3-30
     */
    private boolean hasCheckCenter() {
        return null != mHomeEntity && null != mHomeEntity.checkloc
                && mHomeEntity.checkloc.lat > 0 && mHomeEntity.checkloc.lon > 0;
    }

    public void onEventMainThread(AttendanceEventList.AttendanceHomeEvent event) {
        dismissWainting();
        if (event.isError()) {
            if ("en".equals(mEns)) {
                showToast("initialization failed。。。");
            } else {
                showToast("初始化失败。。。");
            }

            finish();
            return;
        }
        mHomeEntity = event.getData();
//        fillUI();

    }

    /**
     * 显示点击显示的结果 2016-4-22
     */
    private void showCheckInResult() {
        showLocalResult(new DialogUtils.DialogOnClickListener() {
            @Override
            public void onClickPositive(Dialog dialog) {
                dialog.cancel();
//                check(1);

            }

            @Override
            public void onClickNegative(Dialog dialog) {
                dialog.cancel();
            }
        });
    }

    /**
     * 签到签退
     *
     * @param checkInOrOut 2016-4-27
     */
    String addr = "";

    private void checkToNet(int checkInOrOut) {

        addr = LocationManager.getDetailAddr(lastDBLocation, false);

        //经度  维度 类型 位置 签到
        mAttendancePresenter.check(String.valueOf(lastDBLocation.getLongitude()), String.valueOf(lastDBLocation.getLatitude()), String.valueOf(attendanceTypeIndex), addr, checkInOrOut);
        if (!"定位".equals(mDingwei)) {
//            tureDialog.show();
//            tureDialog.setTextTitleAndBt(addr, getString(R.string.qiandao));
            if ("上班".equals(mDingwei)) {
                setJsonString();
            } else if ("中午".equals(mDingwei)) {
                setNoonData();
            } else if ("下班".equals(mDingwei)) {
                setOffWorkData();
            }

        }


    }


    public void setJsonString() {
        String mChange = "";
        JSONObject object = new JSONObject();

        try {
            object.put("bgsj", getDateTime());
            object.put("qdzb", String.valueOf(lastDBLocation.getLongitude()) + "," + String.valueOf(lastDBLocation.getLatitude()));
            object.put("qddz", addr);
            object.put("kqrq", getDatea());

            if (boolSb && boolZw && boolXb) {

            } else {
             //   object.put("id", settings.getString("ID", " "));
                object.put("id", kqId);
            }
            mChange = "[" + object.toString() + "]";
            System.out.println(mChange);

        } catch (JSONException e) {

            e.printStackTrace();
        }
        sendDataHttp_(mChange);
//        sendDataHttp_();
    }


//存ID
//    SharedPreferences pref = this.getSharedPreferences("dataId",MODE_PRIVATE);
//    SharedPreferences.Editor editor = pref.edit();


    public void sendDataHttp_(String mChange) {
        if(isStop){
            return;
        }
        HttpUtils utils = new HttpUtils();
        RequestParams params = new RequestParams();
        params.addBodyParameter("binding", RunTimeManager.getInstance().getServerBinding());
        if (boolSb && boolZw && boolXb) {
            params.addBodyParameter("serviceName", "insert");//普通插入服务

        } else {
            params.addBodyParameter("serviceName", "update");//普通更新服务
        }
        params.addBodyParameter("objectApiName", "kqxx");
        params.addBodyParameter("data", mChange);

//        、、、、、、、、、、、、、、
        Intent intents = new Intent(this, GongniuPhotoActivity.class);
        intents.putExtra("boolSb", boolSb);
        intents.putExtra("boolZw", boolZw);
        intents.putExtra("boolXb", boolXb);
        intents.putExtra("mChange", mChange);
        intents.putExtra("addr", addr);
        intents.putExtra("mDingwei", mDingwei);
        startActivity(intents);




        return;
//、、、、、、、、、、、、、、、、、、
//        if (boolSb && boolZw && boolXb) {
//            Log.d("request上班数据接口url---", UrlManager.getInterfaceUrl() + "?binding=" + RunTimeManager.getInstance().getServerBinding() + "&serviceName=insert&objectApiName=kqxx&data=" + mChange);
//        } else {
//
//            Log.d("request上班数据接口url---", UrlManager.getInterfaceUrl() + "?binding=" + RunTimeManager.getInstance().getServerBinding() + "&serviceName=update&objectApiName=kqxx&data=" + mChange);
//
//        }

//        utils.send(HttpRequest.HttpMethod.POST, UrlManager.getInterfaceUrl(), params,
//                new RequestCallBack<String>() {
//
//                    @Override
//                    public void onFailure(HttpException arg0, String arg1) {
//
//
//                        Log.d("request上班上传数据接口失败-------------------------", arg1);
//                    }
//
//                    @Override
//                    public void onSuccess(ResponseInfo<String> arg0) {
//
//                        getDataSend();
//                        Log.d("request上班上传数据接口成功-------------------------", arg0.result);
//                        if (boolSb && boolZw && boolXb) {
//                            NCheckIdBean dataId = new Gson().fromJson(arg0.result, NCheckIdBean.class);
//                            if (dataId.data.ids.isEmpty()) {
//                                return;
//                            }
//                            NCheckIdBean.DataId.CheckId ss = dataId.data.ids.get(0);//有可能数组越界，
//                            String id = ss.id;
//                            editor.putString("ID", id);
//                            editor.commit();
//                        }
//                    }
//                });
    }

    public String getDateTime() {
        Date d = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        return sdf.format(d);
    }

    public String getDatea() {
        Date d = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

        return sdf.format(d);
//        return "('" + sdf.format(d) + "','yyyy-MM-dd')";
    }


    public void setNoonData() {
        String mChange = "";
        JSONObject object = new JSONObject();

        try {
            object.put("zwbgsj", getDateTime());
            object.put("zwqdzb", String.valueOf(lastDBLocation.getLongitude()) + "," + String.valueOf(lastDBLocation.getLatitude()));
            object.put("zwqddz", addr);
            object.put("kqrq", getDatea());
            if (boolSb && boolZw && boolXb) {

            } else {
              //  object.put("id", settings.getString("ID", " "));
                object.put("id", kqId);
            }
            mChange = "[" + object.toString() + "]";
            System.out.println(mChange);

        } catch (JSONException e) {

            e.printStackTrace();
        }
        sendDataHttp_(mChange);
//        sendDataHttp_();
    }

    public void setOffWorkData() {
        String mChange = "";
        JSONObject object = new JSONObject();

        try {
            object.put("xbbgsj", getDateTime());
            object.put("xbqtzb", String.valueOf(lastDBLocation.getLongitude()) + "," + String.valueOf(lastDBLocation.getLatitude()));
            object.put("xbqtdz", addr);
            object.put("kqrq", getDatea());
            if (boolSb && boolZw && boolXb) {

            } else {
               // object.put("id", settings.getString("ID", " "));
                object.put("id", kqId);
            }
            mChange = "[" + object.toString() + "]";
            System.out.println(mChange);

        } catch (JSONException e) {

            e.printStackTrace();
        }
        sendDataHttp_(mChange);
//        sendDataHttp_();
    }

    public CheckInBean mSucc;

    public void getDataSend() {
        String expressionsStr = "";
        String fieldsStr = "";
        String b = RunTimeManager.getInstance().getServerBinding();
        String u = UrlManager.getInterfaceUrl();
        HttpUtils utils = new HttpUtils();
        RequestParams params = new RequestParams();
        params.addBodyParameter("binding", RunTimeManager.getInstance().getServerBinding());
        params.addBodyParameter("serviceName", "cquery");//普通插入服务
        params.addBodyParameter("objectApiName", "kqxx");


        // &expressions=kqrq=to_date('2017-11-02','yyyy-mm-dd') and ownerid='005cca20161207UlYIP8'


        String express = "kqrq=to_date('" + getDatea() + "','yyyy-mm-dd') and ownerid='" + RunTimeManager.getInstance().getUserId() + "'";

        params.addBodyParameter("expressions", "kqrq=to_date('" + getDatea() + "','yyyy-mm-dd') and ownerid='" + RunTimeManager.getInstance().getUserId() + "'");

//        params.addBodyParameter("expressions", "1 = 1 ORDER BY createdate DESC");
//        params.addBodyParameter("kqrq", getDatea());


        Log.d("request获取三条数据接口url---", u + "?binding=" + b + "&serviceName=cquery&objectApiName=kqxx&expressions=" + express);

        utils.send(HttpRequest.HttpMethod.POST, UrlManager.getInterfaceUrl(), params,
                new RequestCallBack<String>() {

                    @Override
                    public void onFailure(HttpException arg0, String arg1) {

                        Log.d("request获取三条数据接口失败-------------------------", arg1);
                    }

                    @Override
                    public void onSuccess(ResponseInfo<String> arg0) {
                        Log.d("request获取三条数据接口成功-------------------------", arg0.result);
                        mSucc = new Gson().fromJson(arg0.result, CheckInBean.class);
                        if (mSucc.data.isEmpty() || mSucc.data.size() == 0) {
//                            boolSb = true;
//                            boolZw = true;
//                            boolXb = true;
//                            imgBtnGowork.setEnabled(true);
//                            imgBtnNoon.setEnabled(true);
//                            imgBtnOffwork.setEnabled(true);
//                            imgBtnGowork.setImageResource(R.drawable.icom_gowork);
//                            imgBtnNoon.setImageResource(R.drawable.icom_nopress);
//                            imgBtnOffwork.setImageResource(R.drawable.icom_xiapress);
                            tvShowTip.setVisibility(View.VISIBLE);
                            return;
                        } else {
                            tvShowTip.setVisibility(View.GONE);
                        }

                       kqId=mSucc.data.get(  mSucc.data.size()-1).getId();
                        editor.putString("kqid",kqId);
                        editor.commit();
                        mAdapter = new NCheckDataAdapter(GongniuCheckinActivity.this, mSucc.data);
                        listCheckIn.setAdapter(mAdapter);
                        mAdapter.notifyDataSetChanged();
                        setButtonLineBtn();
                    }
                });
    }

    public boolean boolSb = true;
    public boolean boolZw = true;
    public boolean boolXb = true;

    public void setButtonLineBtn() {
        if (mAdapter.getSb()) {
            imgBtnGowork.setEnabled(true);
            boolSb = true;
            imgBtnGowork.setImageResource(R.drawable.icom_gowork);
        } else {
            imgBtnGowork.setEnabled(false);
            boolSb = false;
            imgBtnGowork.setImageResource(R.drawable.icom_offwork);
        }

        if (mAdapter.getZw()) {
            imgBtnNoon.setEnabled(true);
            boolZw = true;
            imgBtnNoon.setImageResource(R.drawable.icom_nopress);
        } else {
            imgBtnNoon.setEnabled(false);
            boolZw = false;
            imgBtnNoon.setImageResource(R.drawable.icom_press);
        }

        if (mAdapter.getXb()) {
            imgBtnOffwork.setEnabled(true);
            boolXb = true;
            imgBtnOffwork.setImageResource(R.drawable.icom_xiapress);
        } else {
            imgBtnOffwork.setEnabled(false);
            boolXb = false;
            imgBtnOffwork.setImageResource(R.drawable.icom_xiayapress);
        }
        if (mSucc.data.isEmpty() || mSucc.data.size() == 0) {
            imgBtnGowork.setEnabled(true);
            imgBtnNoon.setEnabled(true);
            imgBtnOffwork.setEnabled(true);
            imgBtnGowork.setImageResource(R.drawable.icom_gowork);
            imgBtnNoon.setImageResource(R.drawable.icom_nopress);
            imgBtnOffwork.setImageResource(R.drawable.icom_xiapress);


        }
    }


    @Override
    public void rightBt() {

        tureDialog.dismiss();
        if ("上班".equals(mDingwei)) {
            setJsonString();
        } else if ("中午".equals(mDingwei)) {
            setNoonData();
        } else if ("下班".equals(mDingwei)) {
            setOffWorkData();
        }

    }



    /**
     * 新建考勤记录 后来的增加的需求
     */


    ////up
//    public void bullUploadPhoto(final List<AddImageInfo> images, final Map<String, String> json,
//                                final DynamicEventList.SendDynamicEvent event, final String isxunjian) {
//        final List<ManyImage> imglist = new ArrayList<ManyImage>();
//        Log.d("imagepath", images.get(0).getImagePath());
//        for (int i = 0; i < images.size(); i++) {
//            File file = new File(images.get(i).getImagePath());
//            if (!file.exists()) {// 如果存在 就放弃
//                continue;
//            }
//            ManyImage image = new ManyImage();
//            image.setImgName(images.get(i).getImagePath());
//            image.setAddress("");
//            image.setImgHeight("");
//            image.setImgWidth("");
//            image.setImgId("");
//            image.setImgType("jpg");
//            imglist.add(image);
//        }
//
//        final String[] imagepaths = new String[imglist.size()];
//
//        for (int i = 0; i < images.size(); i++) {
//            imagepaths[i] = images.get(i).getImagePath();
//            ManyImage image = new ManyImage();
//            image.setImgName(images.get(i).getImagePath());
//            image.setAddress("");
//            image.setImgHeight("");
//            image.setImgWidth("");
//            image.setImgId("");
//            image.setImgType("jpg");
//            imglist.add(image);
//        }
//        String paramImages = GsonUtil.Object2Json(imglist);
//        String decode1 = paramImages.replaceAll(" ", "%20");
//        String decode = decode1;
//        Log.d("decode", "decode:" + decode);
//        try {
//            decode = URLEncoder.encode(decode1, "UTF-8");
//
//        } catch (UnsupportedEncodingException e1) {
//            e1.printStackTrace();
//        }
//
//        RequestParams params = new RequestParams();
//
//        for (int i = 0; i < imagepaths.length; i++) {
//            try {
//                File file = new File(imagepaths[i]);
//                params.put("file" + (i + 1), file, file.getName());
//            } catch (FileNotFoundException e) {
//                e.printStackTrace();
//            }
//        }
//
//        String host = StringUtils.replace(UrlManager.getInterfaceUrl(),
//                "https://", "http://");
//
//        final String url = host + "?serviceName=uploadImgMany&data=" + decode
//                + "&binding=" + RunTimeManager.getInstance().getServerBinding();
//
//        AsyncClient.getInstance().post(
//                url,
//                params,
//                new GsonHttpResponseHandler<PopjModelList.UploadBitmapPopj>(
//                        PopjModelList.UploadBitmapPopj.class, null) {
//                    @Override
//                    public void onSuccess(PopjModelList.UploadBitmapPopj t) {// 请求转换成
//                        Log.d("onSuccess", "成功"); // jsonbean成功
//                        // 发布 微贴
//                        String[] imageIds = t.data.imgId;
//                        if (imageIds == null || imageIds.length == 0) {
//                            onFailure(new ErrorInfo(101, "上传图片失败"));
//                        }
//
//                        StringBuilder sb = new StringBuilder();
//                        for (int i = 0; i < imageIds.length; i++) {
//                            sb.append(imageIds[i] + ",");
//                        }
//
//                        String a = sb.toString();
//                        if ("yeah".equals(isxunjian)) {
////                        sendBull(createJson(json,imageIds), event,
////                            "insert");
//                        } else {
////                        sendBullJob(createJsonNewjob(json,imageIds),event,"insert");
//                        }
//
//
//                    }
//
//
//                });
//
//    }
}


